﻿using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using ET;

namespace Marx
{
    public class EditorAssetLoader : IResLoader
    {
        public T LoadAsset<T>(string path) where T : UnityEngine.Object
        {
#if UNITY_EDITOR
            var realPath = FileHelper.GetABResPath(path);
            return UnityEditor.AssetDatabase.LoadAssetAtPath<T>(realPath);
#else
            throw new Exception("Dev Resloader Component cant use in released package");
#endif
        }

        public TextAsset LoadText(string path)
        {
            return LoadAsset<TextAsset>(path);
        }

        public GameObject LoadPrefab(string path)
        {
            return LoadAsset<GameObject>(path);
        }

        public async ETTask<T> LoadAssetAsync<T>(string path) where T : UnityEngine.Object
        {
            await ETTask.CompletedTask;
            return LoadAsset<T>(path);
        }

        public ETTask<TextAsset> LoadTextAsync(string path)
        {
            return LoadAssetAsync<TextAsset>(path);
        }

        public ETTask<GameObject> LoadPrefabAsync(string path)
        {
            return LoadAssetAsync<GameObject>(path);
        }

        public void LoadBundle(string bundleName)
        {

        }

        public string LoadBundleByAsset(string path)
        {
            return null;
        }

        public void UnloadBundle(string bundleName, bool force)
        {
        }

        public void UnloadBundleByAsset(string path, bool force)
        {
        }

    }
}
